<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
	<style>
		#box{
			width:200px; height:200px; background:red;
		}
	</style>
 </head>
 <body>
		<div id="box"></div>
 </body>
</html>
<script>
	//获取元素
	var oBox = document.getElementById('box');

	//默认为红色，点击一次变黄，再点击变红.....
	//直接改变
	

	//点击事件
	var count = 'red'; //信号量  改全局变量

	oBox.onclick = function(){
		//点击当它是红色的时候就变黄，是黄色的时候就变红
		if(count == 'red'){
			//oBox.style.background = 'yellow';
			count = 'yellow';
		}else{
			//oBox.style.background = 'red';
			count = 'red';
		}
		//最终结果只是围绕信号量去做的改变
		oBox.style.background = count;
	}
</script>
